package com.hb0730.boot.admin.modules.sci.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hb0730.boot.admin.modules.sci.model.entity.SciMessage;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

public interface SciMessageMapper extends BaseMapper<SciMessage> {
    void updateProStatus( String tableName, SciMessage sciMessage);


    @Select({
            "<script>",
            "SELECT sm.id AS id, sm.type AS msg_type, dt.*, sm.* ",
            "FROM ${tableName} dt ",
            "LEFT JOIN sci_msg sm ON dt.id = sm.sci_id ",
            "WHERE dt.id IN ",
            "<foreach collection='sciIds' item='sciId' open='(' close=')' separator=','> ",
            "#{sciId} ",
            "</foreach>",
            "ORDER BY sm.modified DESC",
            "</script>"
    })
    List<Map<String, Object>> getSciList(String tableName, List<String> sciIds);

    @Select("select id from sci_msg where sci_id = #{sciId}")
    String findIdBySciId(String sciId);

    boolean deleteByMsg(String tableName,SciMessage sciMessage);

    boolean deleteBySciIds(List<String> ids);
}
